package com.cattest.cattest.service.impl;

import com.cattest.cattest.service.CatFunctionService;
import com.dianping.cat.Cat;
import com.dianping.cat.message.Transaction;
import com.sml.aop.cat.CatMethodAnnotation;
import org.springframework.stereotype.Service;

/**
 * @Author linlx
 * @Date 2021/8/26 11:12
 * @Description
 **/
@Service
public class CatFunctionServiceImpl implements CatFunctionService {

  @Override
  public String transaction() {
    Transaction transaction = Cat.newTransaction("URL", "transaction");
    try {
      // do something
      int i = 1 / 0;
      transaction.setStatus(Transaction.SUCCESS);
    } catch (Exception e) {
      transaction.setStatus(e);
    } finally {
      transaction.complete();
    }
    return "ok";
  }

  @Override
  @CatMethodAnnotation
  public void catMethodAnnotation() {

  }


}
